package question5.com.qee.jdbc;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 * @ProjectName: learning
 * @Package: question5.com.qee.jdbc
 * @ClassName: Test
 * @Description:
 * @Date: 2021/10/15 3:57 下午
 * @Version: 1.0
 */
public class HikariUserDaoTest {


    public static void main(String[] args) throws SQLException, ClassNotFoundException {
         insert();

      // delete();
      //   update();
    }

    private static void delete() {

        for (int i = 0; i < 100; i++) {
            UserDao userDao = new HikariUserDaoImpl();
            userDao.remove((long) i);
        }
        UserDao userDao = new HikariUserDaoImpl();
        List<User> all = userDao.getAll();
        for (User user : all) {
            System.out.println(user);
        }
    }

    private static void insert() throws SQLException {

        for (int i = 0; i < 100; i++) {
            UserDao userDao = new HikariUserDaoImpl();
            User user = new User();
            user.setId((long) i);
            user.setCreateTime(new Date());
            user.setUpdateTime(new Date());
            user.setFeature("feature=>" + i);
            user.setName("name" + i);
            userDao.add(user);
        }
        UserDao userDao = new HikariUserDaoImpl();
        List<User> all = userDao.getAll();
        for (User user : all) {
            System.out.println(user);
        }
    }

    public static void update() {

        UserDao userDao = new HikariUserDaoImpl();
        User user = new User();
        user.setId(1L);
        user.setCreateTime(new Date());
        user.setUpdateTime(new Date());
        user.setFeature("feature=>new");
        user.setName("name1");
        userDao.update(user);


        List<User> all = userDao.getAll();
        for (User user1 : all) {
            System.out.println(user1);
        }

    }
}
